// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

#include "stdafx.h"

BOOL APIENTRY DllMain(
    HMODULE module,
    DWORD reason,
    LPVOID reserved)
{
    UNREFERENCED_PARAMETER(module);
    UNREFERENCED_PARAMETER(reserved);

    switch (reason)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}


//
// WARNING: 
//
// The signature below MUST exactly match (including the parameter names)
// with the signature generated by MIDL in the FabricStore.h file. 
// Otherwise the linker does not apply the extern "C" specifier and exports 
// this function as C++ name mangled function instead of C style function.
// 
/* [entry] */ HRESULT CreateFabricTokenValidationServiceAgent( 
    /* [in] */ __RPC__in REFIID riid,
    /* [out, retval] */ __RPC__deref_out_opt void ** fabricTokenValidationServiceAgent)
{
    Api::ITokenValidationServiceAgentFactoryPtr factoryPtr = Management::TokenValidationService::TokenValidationServiceAgentFactory::Create();

    Api::ComTokenValidationServiceAgentFactory comFactory(factoryPtr);

    return comFactory.CreateFabricTokenValidationServiceAgent(riid, fabricTokenValidationServiceAgent);
}

/* [entry] */ HRESULT GetDefaultAzureActiveDirectoryConfigurations( 
    /* [out, retval] */ IFabricStringMapResult ** result)
{
    auto configs = Common::SecurityConfig::GetConfig().GetDefaultAzureActiveDirectoryConfigurations();

    auto comResult = Common::make_com<Api::ComStringMapResult>(move(configs));

    *result = comResult.DetachNoRelease();

    return S_OK;
}
